﻿using System.Collections.Generic;
using XLua;
#if USE_UNI_LUA
using LuaAPI = UniLua.Lua;
using RealStatePtr = UniLua.ILuaState;
using LuaCSFunction = UniLua.CSharpFunctionDelegate;
#else
using LuaAPI = XLua.LuaDLL.Lua;
using RealStatePtr = System.IntPtr;
using LuaCSFunction = XLua.LuaDLL.lua_CSFunction;
#endif

namespace XLua.CSObjectWrap
{
    using Utils = XLua.Utils;

    public class UnityEngineVector2Wrap
    {
        public static void __Register(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
            System.Type type = typeof(UnityEngine.Vector2);
            Utils.BeginObjectRegister(type, L, translator, 6, 7, 5, 2);
            Utils.RegisterFunc(L, Utils.OBJ_META_IDX, "__add", __AddMeta);
            Utils.RegisterFunc(L, Utils.OBJ_META_IDX, "__sub", __SubMeta);
            Utils.RegisterFunc(L, Utils.OBJ_META_IDX, "__mul", __MulMeta);
            Utils.RegisterFunc(L, Utils.OBJ_META_IDX, "__div", __DivMeta);
            Utils.RegisterFunc(L, Utils.OBJ_META_IDX, "__unm", __UnmMeta);
            Utils.RegisterFunc(L, Utils.OBJ_META_IDX, "__eq", __EqMeta);

            Utils.RegisterFunc(L, Utils.METHOD_IDX, "Set", _m_Set);
            Utils.RegisterFunc(L, Utils.METHOD_IDX, "Scale", _m_Scale);
            Utils.RegisterFunc(L, Utils.METHOD_IDX, "Normalize", _m_Normalize);
            Utils.RegisterFunc(L, Utils.METHOD_IDX, "ToString", _m_ToString);
            Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetHashCode", _m_GetHashCode);
            Utils.RegisterFunc(L, Utils.METHOD_IDX, "Equals", _m_Equals);
            Utils.RegisterFunc(L, Utils.METHOD_IDX, "SqrMagnitude", _m_SqrMagnitude);

            Utils.RegisterFunc(L, Utils.GETTER_IDX, "normalized", _g_get_normalized);
            Utils.RegisterFunc(L, Utils.GETTER_IDX, "magnitude", _g_get_magnitude);
            Utils.RegisterFunc(L, Utils.GETTER_IDX, "sqrMagnitude", _g_get_sqrMagnitude);
            Utils.RegisterFunc(L, Utils.GETTER_IDX, "x", _g_get_x);
            Utils.RegisterFunc(L, Utils.GETTER_IDX, "y", _g_get_y);

            Utils.RegisterFunc(L, Utils.SETTER_IDX, "x", _s_set_x);
            Utils.RegisterFunc(L, Utils.SETTER_IDX, "y", _s_set_y);

            Utils.EndObjectRegister(
                type,
                L,
                translator,
                __CSIndexer,
                __NewIndexer,
                null,
                null,
                null
            );

            Utils.BeginClassRegister(type, L, __CreateInstance, 18, 8, 0);
            Utils.RegisterFunc(L, Utils.CLS_IDX, "Lerp", _m_Lerp_xlua_st_);
            Utils.RegisterFunc(L, Utils.CLS_IDX, "LerpUnclamped", _m_LerpUnclamped_xlua_st_);
            Utils.RegisterFunc(L, Utils.CLS_IDX, "MoveTowards", _m_MoveTowards_xlua_st_);
            Utils.RegisterFunc(L, Utils.CLS_IDX, "Scale", _m_Scale_xlua_st_);
            Utils.RegisterFunc(L, Utils.CLS_IDX, "Reflect", _m_Reflect_xlua_st_);
            Utils.RegisterFunc(L, Utils.CLS_IDX, "Perpendicular", _m_Perpendicular_xlua_st_);
            Utils.RegisterFunc(L, Utils.CLS_IDX, "Dot", _m_Dot_xlua_st_);
            Utils.RegisterFunc(L, Utils.CLS_IDX, "Angle", _m_Angle_xlua_st_);
            Utils.RegisterFunc(L, Utils.CLS_IDX, "SignedAngle", _m_SignedAngle_xlua_st_);
            Utils.RegisterFunc(L, Utils.CLS_IDX, "Distance", _m_Distance_xlua_st_);
            Utils.RegisterFunc(L, Utils.CLS_IDX, "ClampMagnitude", _m_ClampMagnitude_xlua_st_);
            Utils.RegisterFunc(L, Utils.CLS_IDX, "SqrMagnitude", _m_SqrMagnitude_xlua_st_);
            Utils.RegisterFunc(L, Utils.CLS_IDX, "Min", _m_Min_xlua_st_);
            Utils.RegisterFunc(L, Utils.CLS_IDX, "Max", _m_Max_xlua_st_);
            Utils.RegisterFunc(L, Utils.CLS_IDX, "SmoothDamp", _m_SmoothDamp_xlua_st_);

            Utils.RegisterObject(
                L,
                translator,
                Utils.CLS_IDX,
                "kEpsilon",
                UnityEngine.Vector2.kEpsilon
            );
            Utils.RegisterObject(
                L,
                translator,
                Utils.CLS_IDX,
                "kEpsilonNormalSqrt",
                UnityEngine.Vector2.kEpsilonNormalSqrt
            );

            Utils.RegisterFunc(L, Utils.CLS_GETTER_IDX, "zero", _g_get_zero);
            Utils.RegisterFunc(L, Utils.CLS_GETTER_IDX, "one", _g_get_one);
            Utils.RegisterFunc(L, Utils.CLS_GETTER_IDX, "up", _g_get_up);
            Utils.RegisterFunc(L, Utils.CLS_GETTER_IDX, "down", _g_get_down);
            Utils.RegisterFunc(L, Utils.CLS_GETTER_IDX, "left", _g_get_left);
            Utils.RegisterFunc(L, Utils.CLS_GETTER_IDX, "right", _g_get_right);
            Utils.RegisterFunc(
                L,
                Utils.CLS_GETTER_IDX,
                "positiveInfinity",
                _g_get_positiveInfinity
            );
            Utils.RegisterFunc(
                L,
                Utils.CLS_GETTER_IDX,
                "negativeInfinity",
                _g_get_negativeInfinity
            );

            Utils.EndClassRegister(type, L, translator);
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int __CreateInstance(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
                if (
                    LuaAPI.lua_gettop(L) == 3
                    && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)
                    && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3)
                )
                {
                    float _x = (float)LuaAPI.lua_tonumber(L, 2);
                    float _y = (float)LuaAPI.lua_tonumber(L, 3);

                    var gen_ret = new UnityEngine.Vector2(_x, _y);
                    translator.PushUnityEngineVector2(L, gen_ret);

                    return 1;
                }

                if (LuaAPI.lua_gettop(L) == 1)
                {
                    translator.PushUnityEngineVector2(L, default(UnityEngine.Vector2));
                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Vector2 constructor!");
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        public static int __CSIndexer(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                if (
                    translator.Assignable<UnityEngine.Vector2>(L, 1)
                    && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)
                )
                {
                    UnityEngine.Vector2 gen_to_be_invoked;
                    translator.Get(L, 1, out gen_to_be_invoked);
                    int index = LuaAPI.xlua_tointeger(L, 2);
                    LuaAPI.lua_pushboolean(L, true);
                    LuaAPI.lua_pushnumber(L, gen_to_be_invoked[index]);
                    return 2;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }

            LuaAPI.lua_pushboolean(L, false);
            return 1;
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        public static int __NewIndexer(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

            try
            {
                if (
                    translator.Assignable<UnityEngine.Vector2>(L, 1)
                    && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)
                    && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3)
                )
                {
                    UnityEngine.Vector2 gen_to_be_invoked;
                    translator.Get(L, 1, out gen_to_be_invoked);
                    int key = LuaAPI.xlua_tointeger(L, 2);
                    gen_to_be_invoked[key] = (float)LuaAPI.lua_tonumber(L, 3);
                    LuaAPI.lua_pushboolean(L, true);
                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }

            LuaAPI.lua_pushboolean(L, false);
            return 1;
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int __AddMeta(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                if (
                    translator.Assignable<UnityEngine.Vector2>(L, 1)
                    && translator.Assignable<UnityEngine.Vector2>(L, 2)
                )
                {
                    UnityEngine.Vector2 leftside;
                    translator.Get(L, 1, out leftside);
                    UnityEngine.Vector2 rightside;
                    translator.Get(L, 2, out rightside);

                    translator.PushUnityEngineVector2(L, leftside + rightside);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return LuaAPI.luaL_error(
                L,
                "invalid arguments to right hand of + operator, need UnityEngine.Vector2!"
            );
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int __SubMeta(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                if (
                    translator.Assignable<UnityEngine.Vector2>(L, 1)
                    && translator.Assignable<UnityEngine.Vector2>(L, 2)
                )
                {
                    UnityEngine.Vector2 leftside;
                    translator.Get(L, 1, out leftside);
                    UnityEngine.Vector2 rightside;
                    translator.Get(L, 2, out rightside);

                    translator.PushUnityEngineVector2(L, leftside - rightside);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return LuaAPI.luaL_error(
                L,
                "invalid arguments to right hand of - operator, need UnityEngine.Vector2!"
            );
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int __MulMeta(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                if (
                    translator.Assignable<UnityEngine.Vector2>(L, 1)
                    && translator.Assignable<UnityEngine.Vector2>(L, 2)
                )
                {
                    UnityEngine.Vector2 leftside;
                    translator.Get(L, 1, out leftside);
                    UnityEngine.Vector2 rightside;
                    translator.Get(L, 2, out rightside);

                    translator.PushUnityEngineVector2(L, leftside * rightside);

                    return 1;
                }

                if (
                    translator.Assignable<UnityEngine.Vector2>(L, 1)
                    && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)
                )
                {
                    UnityEngine.Vector2 leftside;
                    translator.Get(L, 1, out leftside);
                    float rightside = (float)LuaAPI.lua_tonumber(L, 2);

                    translator.PushUnityEngineVector2(L, leftside * rightside);

                    return 1;
                }

                if (
                    LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 1)
                    && translator.Assignable<UnityEngine.Vector2>(L, 2)
                )
                {
                    float leftside = (float)LuaAPI.lua_tonumber(L, 1);
                    UnityEngine.Vector2 rightside;
                    translator.Get(L, 2, out rightside);

                    translator.PushUnityEngineVector2(L, leftside * rightside);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return LuaAPI.luaL_error(
                L,
                "invalid arguments to right hand of * operator, need UnityEngine.Vector2!"
            );
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int __DivMeta(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                if (
                    translator.Assignable<UnityEngine.Vector2>(L, 1)
                    && translator.Assignable<UnityEngine.Vector2>(L, 2)
                )
                {
                    UnityEngine.Vector2 leftside;
                    translator.Get(L, 1, out leftside);
                    UnityEngine.Vector2 rightside;
                    translator.Get(L, 2, out rightside);

                    translator.PushUnityEngineVector2(L, leftside / rightside);

                    return 1;
                }

                if (
                    translator.Assignable<UnityEngine.Vector2>(L, 1)
                    && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)
                )
                {
                    UnityEngine.Vector2 leftside;
                    translator.Get(L, 1, out leftside);
                    float rightside = (float)LuaAPI.lua_tonumber(L, 2);

                    translator.PushUnityEngineVector2(L, leftside / rightside);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return LuaAPI.luaL_error(
                L,
                "invalid arguments to right hand of / operator, need UnityEngine.Vector2!"
            );
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int __UnmMeta(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
            try
            {
                UnityEngine.Vector2 rightside;
                translator.Get(L, 1, out rightside);
                translator.PushUnityEngineVector2(L, -rightside);
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 1;
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int __EqMeta(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                if (
                    translator.Assignable<UnityEngine.Vector2>(L, 1)
                    && translator.Assignable<UnityEngine.Vector2>(L, 2)
                )
                {
                    UnityEngine.Vector2 leftside;
                    translator.Get(L, 1, out leftside);
                    UnityEngine.Vector2 rightside;
                    translator.Get(L, 2, out rightside);

                    LuaAPI.lua_pushboolean(L, leftside == rightside);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return LuaAPI.luaL_error(
                L,
                "invalid arguments to right hand of == operator, need UnityEngine.Vector2!"
            );
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_Set(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.Vector2 gen_to_be_invoked;
                translator.Get(L, 1, out gen_to_be_invoked);

                {
                    float _newX = (float)LuaAPI.lua_tonumber(L, 2);
                    float _newY = (float)LuaAPI.lua_tonumber(L, 3);

                    gen_to_be_invoked.Set(_newX, _newY);

                    translator.UpdateUnityEngineVector2(L, 1, gen_to_be_invoked);

                    return 0;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_Lerp_xlua_st_(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                {
                    UnityEngine.Vector2 _a;
                    translator.Get(L, 1, out _a);
                    UnityEngine.Vector2 _b;
                    translator.Get(L, 2, out _b);
                    float _t = (float)LuaAPI.lua_tonumber(L, 3);

                    var gen_ret = UnityEngine.Vector2.Lerp(_a, _b, _t);
                    translator.PushUnityEngineVector2(L, gen_ret);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_LerpUnclamped_xlua_st_(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                {
                    UnityEngine.Vector2 _a;
                    translator.Get(L, 1, out _a);
                    UnityEngine.Vector2 _b;
                    translator.Get(L, 2, out _b);
                    float _t = (float)LuaAPI.lua_tonumber(L, 3);

                    var gen_ret = UnityEngine.Vector2.LerpUnclamped(_a, _b, _t);
                    translator.PushUnityEngineVector2(L, gen_ret);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_MoveTowards_xlua_st_(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                {
                    UnityEngine.Vector2 _current;
                    translator.Get(L, 1, out _current);
                    UnityEngine.Vector2 _target;
                    translator.Get(L, 2, out _target);
                    float _maxDistanceDelta = (float)LuaAPI.lua_tonumber(L, 3);

                    var gen_ret = UnityEngine.Vector2.MoveTowards(
                        _current,
                        _target,
                        _maxDistanceDelta
                    );
                    translator.PushUnityEngineVector2(L, gen_ret);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_Scale_xlua_st_(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                {
                    UnityEngine.Vector2 _a;
                    translator.Get(L, 1, out _a);
                    UnityEngine.Vector2 _b;
                    translator.Get(L, 2, out _b);

                    var gen_ret = UnityEngine.Vector2.Scale(_a, _b);
                    translator.PushUnityEngineVector2(L, gen_ret);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_Scale(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.Vector2 gen_to_be_invoked;
                translator.Get(L, 1, out gen_to_be_invoked);

                {
                    UnityEngine.Vector2 _scale;
                    translator.Get(L, 2, out _scale);

                    gen_to_be_invoked.Scale(_scale);

                    translator.UpdateUnityEngineVector2(L, 1, gen_to_be_invoked);

                    return 0;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_Normalize(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.Vector2 gen_to_be_invoked;
                translator.Get(L, 1, out gen_to_be_invoked);

                {
                    gen_to_be_invoked.Normalize();

                    translator.UpdateUnityEngineVector2(L, 1, gen_to_be_invoked);

                    return 0;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_ToString(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.Vector2 gen_to_be_invoked;
                translator.Get(L, 1, out gen_to_be_invoked);

                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 1)
                {
                    var gen_ret = gen_to_be_invoked.ToString();
                    LuaAPI.lua_pushstring(L, gen_ret);

                    translator.UpdateUnityEngineVector2(L, 1, gen_to_be_invoked);

                    return 1;
                }
                if (
                    gen_param_count == 2
                    && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)
                )
                {
                    string _format = LuaAPI.lua_tostring(L, 2);

                    var gen_ret = gen_to_be_invoked.ToString(_format);
                    LuaAPI.lua_pushstring(L, gen_ret);

                    translator.UpdateUnityEngineVector2(L, 1, gen_to_be_invoked);

                    return 1;
                }
                if (
                    gen_param_count == 3
                    && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING)
                    && translator.Assignable<System.IFormatProvider>(L, 3)
                )
                {
                    string _format = LuaAPI.lua_tostring(L, 2);
                    System.IFormatProvider _formatProvider = (System.IFormatProvider)
                        translator.GetObject(L, 3, typeof(System.IFormatProvider));

                    var gen_ret = gen_to_be_invoked.ToString(_format, _formatProvider);
                    LuaAPI.lua_pushstring(L, gen_ret);

                    translator.UpdateUnityEngineVector2(L, 1, gen_to_be_invoked);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }

            return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Vector2.ToString!");
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_GetHashCode(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.Vector2 gen_to_be_invoked;
                translator.Get(L, 1, out gen_to_be_invoked);

                {
                    var gen_ret = gen_to_be_invoked.GetHashCode();
                    LuaAPI.xlua_pushinteger(L, gen_ret);

                    translator.UpdateUnityEngineVector2(L, 1, gen_to_be_invoked);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_Equals(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.Vector2 gen_to_be_invoked;
                translator.Get(L, 1, out gen_to_be_invoked);

                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 2 && translator.Assignable<object>(L, 2))
                {
                    object _other = translator.GetObject(L, 2, typeof(object));

                    var gen_ret = gen_to_be_invoked.Equals(_other);
                    LuaAPI.lua_pushboolean(L, gen_ret);

                    translator.UpdateUnityEngineVector2(L, 1, gen_to_be_invoked);

                    return 1;
                }
                if (gen_param_count == 2 && translator.Assignable<UnityEngine.Vector2>(L, 2))
                {
                    UnityEngine.Vector2 _other;
                    translator.Get(L, 2, out _other);

                    var gen_ret = gen_to_be_invoked.Equals(_other);
                    LuaAPI.lua_pushboolean(L, gen_ret);

                    translator.UpdateUnityEngineVector2(L, 1, gen_to_be_invoked);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }

            return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Vector2.Equals!");
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_Reflect_xlua_st_(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                {
                    UnityEngine.Vector2 _inDirection;
                    translator.Get(L, 1, out _inDirection);
                    UnityEngine.Vector2 _inNormal;
                    translator.Get(L, 2, out _inNormal);

                    var gen_ret = UnityEngine.Vector2.Reflect(_inDirection, _inNormal);
                    translator.PushUnityEngineVector2(L, gen_ret);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_Perpendicular_xlua_st_(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                {
                    UnityEngine.Vector2 _inDirection;
                    translator.Get(L, 1, out _inDirection);

                    var gen_ret = UnityEngine.Vector2.Perpendicular(_inDirection);
                    translator.PushUnityEngineVector2(L, gen_ret);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_Dot_xlua_st_(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                {
                    UnityEngine.Vector2 _lhs;
                    translator.Get(L, 1, out _lhs);
                    UnityEngine.Vector2 _rhs;
                    translator.Get(L, 2, out _rhs);

                    var gen_ret = UnityEngine.Vector2.Dot(_lhs, _rhs);
                    LuaAPI.lua_pushnumber(L, gen_ret);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_Angle_xlua_st_(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                {
                    UnityEngine.Vector2 _from;
                    translator.Get(L, 1, out _from);
                    UnityEngine.Vector2 _to;
                    translator.Get(L, 2, out _to);

                    var gen_ret = UnityEngine.Vector2.Angle(_from, _to);
                    LuaAPI.lua_pushnumber(L, gen_ret);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_SignedAngle_xlua_st_(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                {
                    UnityEngine.Vector2 _from;
                    translator.Get(L, 1, out _from);
                    UnityEngine.Vector2 _to;
                    translator.Get(L, 2, out _to);

                    var gen_ret = UnityEngine.Vector2.SignedAngle(_from, _to);
                    LuaAPI.lua_pushnumber(L, gen_ret);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_Distance_xlua_st_(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                {
                    UnityEngine.Vector2 _a;
                    translator.Get(L, 1, out _a);
                    UnityEngine.Vector2 _b;
                    translator.Get(L, 2, out _b);

                    var gen_ret = UnityEngine.Vector2.Distance(_a, _b);
                    LuaAPI.lua_pushnumber(L, gen_ret);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_ClampMagnitude_xlua_st_(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                {
                    UnityEngine.Vector2 _vector;
                    translator.Get(L, 1, out _vector);
                    float _maxLength = (float)LuaAPI.lua_tonumber(L, 2);

                    var gen_ret = UnityEngine.Vector2.ClampMagnitude(_vector, _maxLength);
                    translator.PushUnityEngineVector2(L, gen_ret);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_SqrMagnitude_xlua_st_(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                {
                    UnityEngine.Vector2 _a;
                    translator.Get(L, 1, out _a);

                    var gen_ret = UnityEngine.Vector2.SqrMagnitude(_a);
                    LuaAPI.lua_pushnumber(L, gen_ret);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_SqrMagnitude(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.Vector2 gen_to_be_invoked;
                translator.Get(L, 1, out gen_to_be_invoked);

                {
                    var gen_ret = gen_to_be_invoked.SqrMagnitude();
                    LuaAPI.lua_pushnumber(L, gen_ret);

                    translator.UpdateUnityEngineVector2(L, 1, gen_to_be_invoked);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_Min_xlua_st_(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                {
                    UnityEngine.Vector2 _lhs;
                    translator.Get(L, 1, out _lhs);
                    UnityEngine.Vector2 _rhs;
                    translator.Get(L, 2, out _rhs);

                    var gen_ret = UnityEngine.Vector2.Min(_lhs, _rhs);
                    translator.PushUnityEngineVector2(L, gen_ret);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_Max_xlua_st_(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                {
                    UnityEngine.Vector2 _lhs;
                    translator.Get(L, 1, out _lhs);
                    UnityEngine.Vector2 _rhs;
                    translator.Get(L, 2, out _rhs);

                    var gen_ret = UnityEngine.Vector2.Max(_lhs, _rhs);
                    translator.PushUnityEngineVector2(L, gen_ret);

                    return 1;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _m_SmoothDamp_xlua_st_(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                int gen_param_count = LuaAPI.lua_gettop(L);

                if (
                    gen_param_count == 4
                    && translator.Assignable<UnityEngine.Vector2>(L, 1)
                    && translator.Assignable<UnityEngine.Vector2>(L, 2)
                    && translator.Assignable<UnityEngine.Vector2>(L, 3)
                    && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 4)
                )
                {
                    UnityEngine.Vector2 _current;
                    translator.Get(L, 1, out _current);
                    UnityEngine.Vector2 _target;
                    translator.Get(L, 2, out _target);
                    UnityEngine.Vector2 _currentVelocity;
                    translator.Get(L, 3, out _currentVelocity);
                    float _smoothTime = (float)LuaAPI.lua_tonumber(L, 4);

                    var gen_ret = UnityEngine.Vector2.SmoothDamp(
                        _current,
                        _target,
                        ref _currentVelocity,
                        _smoothTime
                    );
                    translator.PushUnityEngineVector2(L, gen_ret);
                    translator.PushUnityEngineVector2(L, _currentVelocity);
                    translator.UpdateUnityEngineVector2(L, 3, _currentVelocity);

                    return 2;
                }
                if (
                    gen_param_count == 5
                    && translator.Assignable<UnityEngine.Vector2>(L, 1)
                    && translator.Assignable<UnityEngine.Vector2>(L, 2)
                    && translator.Assignable<UnityEngine.Vector2>(L, 3)
                    && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 4)
                    && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 5)
                )
                {
                    UnityEngine.Vector2 _current;
                    translator.Get(L, 1, out _current);
                    UnityEngine.Vector2 _target;
                    translator.Get(L, 2, out _target);
                    UnityEngine.Vector2 _currentVelocity;
                    translator.Get(L, 3, out _currentVelocity);
                    float _smoothTime = (float)LuaAPI.lua_tonumber(L, 4);
                    float _maxSpeed = (float)LuaAPI.lua_tonumber(L, 5);

                    var gen_ret = UnityEngine.Vector2.SmoothDamp(
                        _current,
                        _target,
                        ref _currentVelocity,
                        _smoothTime,
                        _maxSpeed
                    );
                    translator.PushUnityEngineVector2(L, gen_ret);
                    translator.PushUnityEngineVector2(L, _currentVelocity);
                    translator.UpdateUnityEngineVector2(L, 3, _currentVelocity);

                    return 2;
                }
                if (
                    gen_param_count == 6
                    && translator.Assignable<UnityEngine.Vector2>(L, 1)
                    && translator.Assignable<UnityEngine.Vector2>(L, 2)
                    && translator.Assignable<UnityEngine.Vector2>(L, 3)
                    && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 4)
                    && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 5)
                    && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 6)
                )
                {
                    UnityEngine.Vector2 _current;
                    translator.Get(L, 1, out _current);
                    UnityEngine.Vector2 _target;
                    translator.Get(L, 2, out _target);
                    UnityEngine.Vector2 _currentVelocity;
                    translator.Get(L, 3, out _currentVelocity);
                    float _smoothTime = (float)LuaAPI.lua_tonumber(L, 4);
                    float _maxSpeed = (float)LuaAPI.lua_tonumber(L, 5);
                    float _deltaTime = (float)LuaAPI.lua_tonumber(L, 6);

                    var gen_ret = UnityEngine.Vector2.SmoothDamp(
                        _current,
                        _target,
                        ref _currentVelocity,
                        _smoothTime,
                        _maxSpeed,
                        _deltaTime
                    );
                    translator.PushUnityEngineVector2(L, gen_ret);
                    translator.PushUnityEngineVector2(L, _currentVelocity);
                    translator.UpdateUnityEngineVector2(L, 3, _currentVelocity);

                    return 2;
                }
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }

            return LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Vector2.SmoothDamp!");
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _g_get_normalized(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.Vector2 gen_to_be_invoked;
                translator.Get(L, 1, out gen_to_be_invoked);
                translator.PushUnityEngineVector2(L, gen_to_be_invoked.normalized);
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 1;
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _g_get_magnitude(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.Vector2 gen_to_be_invoked;
                translator.Get(L, 1, out gen_to_be_invoked);
                LuaAPI.lua_pushnumber(L, gen_to_be_invoked.magnitude);
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 1;
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _g_get_sqrMagnitude(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.Vector2 gen_to_be_invoked;
                translator.Get(L, 1, out gen_to_be_invoked);
                LuaAPI.lua_pushnumber(L, gen_to_be_invoked.sqrMagnitude);
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 1;
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _g_get_zero(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
                translator.PushUnityEngineVector2(L, UnityEngine.Vector2.zero);
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 1;
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _g_get_one(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
                translator.PushUnityEngineVector2(L, UnityEngine.Vector2.one);
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 1;
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _g_get_up(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
                translator.PushUnityEngineVector2(L, UnityEngine.Vector2.up);
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 1;
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _g_get_down(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
                translator.PushUnityEngineVector2(L, UnityEngine.Vector2.down);
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 1;
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _g_get_left(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
                translator.PushUnityEngineVector2(L, UnityEngine.Vector2.left);
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 1;
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _g_get_right(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
                translator.PushUnityEngineVector2(L, UnityEngine.Vector2.right);
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 1;
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _g_get_positiveInfinity(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
                translator.PushUnityEngineVector2(L, UnityEngine.Vector2.positiveInfinity);
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 1;
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _g_get_negativeInfinity(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
                translator.PushUnityEngineVector2(L, UnityEngine.Vector2.negativeInfinity);
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 1;
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _g_get_x(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.Vector2 gen_to_be_invoked;
                translator.Get(L, 1, out gen_to_be_invoked);
                LuaAPI.lua_pushnumber(L, gen_to_be_invoked.x);
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 1;
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _g_get_y(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.Vector2 gen_to_be_invoked;
                translator.Get(L, 1, out gen_to_be_invoked);
                LuaAPI.lua_pushnumber(L, gen_to_be_invoked.y);
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 1;
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _s_set_x(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.Vector2 gen_to_be_invoked;
                translator.Get(L, 1, out gen_to_be_invoked);
                gen_to_be_invoked.x = (float)LuaAPI.lua_tonumber(L, 2);

                translator.UpdateUnityEngineVector2(L, 1, gen_to_be_invoked);
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 0;
        }

        [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
        static int _s_set_y(RealStatePtr L)
        {
            try
            {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                UnityEngine.Vector2 gen_to_be_invoked;
                translator.Get(L, 1, out gen_to_be_invoked);
                gen_to_be_invoked.y = (float)LuaAPI.lua_tonumber(L, 2);

                translator.UpdateUnityEngineVector2(L, 1, gen_to_be_invoked);
            }
            catch (System.Exception gen_e)
            {
                return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
            }
            return 0;
        }
    }
}
